if __name__ == '__main__':
    print("开始学习元组")
    """
        初学python，很容易犯这样的错误，即直接用set, list, tuple, dict, str, int, complex, 
        float等作为变量名。这样会导致这些内置函数：set(), list(), tuple()等等无法执行。
        
        这里要特别的注意啊，我这里就犯错了，变量名是用了tuple
    """
    tuple1 = ("gao",333,555);
    print(type(tuple1));
    value = tuple1[0];
    print(value);
    #这里特别的注意啊，不行，不能修改，java中是可以的
    #tuple[0] = "22222";
    print(tuple1);

    #定义一个空元组,很少用，没啥意思
    tuple2 = ();
    print(tuple2);

    single_tuple = (5);
    print(type(single_tuple));
    single_tuple = (5,);
    print(type(single_tuple));

    tuple2 = ("gao", 333, 555);
    print(tuple2[0]);
    print(tuple2.index(333));
    print(len(tuple2));
    #获取某个值在元组中出现的次数
    print(tuple2.count("gao2"));

    #元组的循环
    for item in tuple2:
        print(item,end="\t");

    print("");
    info_tuple = ("小明",26,17);
    print("%s 的年龄是 %d 身高是 %.2f 厘米" % info_tuple);

    #使用元组拼接一个新的字符串
    info_str = "%s 的年龄是 %d 身高是 %.2f 厘米" % info_tuple;
    print(info_str);

    #列表转数组和数组转列表
    print("列表转元组")
    num_list1 = [12,13,13,444];
    num_tuple = tuple(num_list1);
    print(num_tuple);

    print("元组转列表")
    num_tuple = (12,44,13,"sss");
    num_list = list(num_tuple);
    print(num_list);






